Software Development
Functions in C++
Functions in C++: Using Default Arguments & Function Overloading
Functions in C++: Using Functions & Parameter Passing

Functions in C++: Using Default Arguments & Function Overloading

Course Number:
it_cpfuncdj_02_enus
Lesson Objectives

Functions in C++: Using Default Arguments & Function Overloading

  • discover the key concepts covered in this course
  • pass in input arguments with default values
  • explore how to return pointers and references from functions
  • use the auto keyword with return values of a function
  • create multiple functions with the same name
  • work with overloading functions
  • split code into header files
  • summarize the key concepts covered in this course

Overview/Description
C++ allows you as the developer to specify default values for the input arguments into your functions, and supports function overloading. Both of these are powerful techniques for code reuse. Explore how to use default argument values for C++ functions, including important rules that govern such default values. Examine the semantics of return values from functions and learn how to avoid the dangling pointer problem. Discover function overloading, learn how to split the declaration and implementation of a function across header and implementation files, and learn the correct way of importing these header files into code to invoke that function. Upon completion, you'll be able to specify default values for function arguments, overload functions based on input arguments and const, and split functions across .h and .cpp files.

Target

Prerequisites: none

Functions in C++: Using Functions & Parameter Passing

Course Number:
it_cpfuncdj_01_enus
Lesson Objectives

Functions in C++: Using Functions & Parameter Passing

  • discover the key concepts covered in this course
  • outline the features of functions in C++
  • create functions and contrast declarations and definitions
  • recognize basic pass-by-value data types
  • recall that strings are passed by value
  • recall that pointers can be passed by value
  • recall how to use pass-by-value with pointers
  • use the pass-by-reference construct
  • recall how references are passed by reference
  • pass in references to vectors
  • pass in references and perform implicit type conversion
  • summarize the key concepts covered in this course

Overview/Description
Functions remain an important construct for code modularization and reuse in C++, even though C++ is an object-oriented language. Learn how to use functions in C++, focusing on free functions, and examine the distinction between declaring a function, where you specify the function’s signature, return type, and name; defining a function, where you create the body of a function; and invoking the function. Then, explore the semantics of passing parameters by value to C++ functions. Finally, compare pass-by-reference semantics to pass-by-value semantics and investigate the differences. Upon completion of this course, you will be able to use pass-by-value and pass-by-reference semantics in the context of function invocation in C++.

Target

Prerequisites: none

Close Chat Live